package com.chenwut.threadDemo.exercise_3;

/**
 * @author ChenPi
 * @since 2024/09/19 16:52
 */
public class MyThread extends Thread {

    static int num = 0;

    @Override
    public void run() {
        while (true) {
            synchronized (MyThread.class) {
                if (num == 200) {
                    break;
                }
                num++;
                if (num % 2 != 0) {
                    System.out.println(getName() + " 打印了 奇数：" + num);
                }

            }
        }
    }
}
